package it.asvp.asvp_portal.data.entity.rent;

import it.asvp.asvp_portal.asvp_util.enumerative.RentType;
import it.asvp.asvp_portal.data.entity.domain.BaseEntity;
import it.asvp.asvp_portal.data.entity.member.Member;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

@SuppressWarnings("serial")
@Entity
@Table(name = "rent", catalog = "asvp_db")
public class Rent extends BaseEntity {

  @ManyToOne(fetch = FetchType.LAZY)
  @JoinColumn(name = "id_member")
  private Member           member;

  @Column(name = "rent_type", nullable = false, length = 50)
  @Enumerated(EnumType.STRING)
  private RentType         rentType;

  @Column(name = "furnished", nullable = false)
  private boolean          furnished;

  @Column(name = "price", precision = 22, scale = 0)
  private Double           price;

  @Column(name = "website_link")
  private String           websiteLink;

  @Column(name = "phone", length = 30)
  private String           phone;

  @Column(name = "email", nullable = false)
  private String           email;

  @Column(name = "description", nullable = false, length = 500)
  private String           description;

  @OneToMany(fetch = FetchType.LAZY, mappedBy = "rent")
  @Cascade({ CascadeType.ALL })
  private Set<RentPicture> rentPictures = new HashSet<RentPicture>(0);

  public Rent() {
  }

  public Rent(RentType rentType, boolean furnished, Date createdOn, String email, String description, Date lastUpdate) {
    this.rentType = rentType;
    this.furnished = furnished;
    this.createdOn = createdOn;
    this.email = email;
    this.description = description;
    this.lastUpdate = lastUpdate;
  }

  public Rent(Member member, RentType rentType, boolean furnished, Double price, String websiteLink, Date createdOn, String phone, String email,
      String description, Date lastUpdate, Set<RentPicture> rentPictures) {
    this.member = member;
    this.rentType = rentType;
    this.furnished = furnished;
    this.price = price;
    this.websiteLink = websiteLink;
    this.createdOn = createdOn;
    this.phone = phone;
    this.email = email;
    this.description = description;
    this.lastUpdate = lastUpdate;
    this.rentPictures = rentPictures;
  }

  public Member getMember() {
    return this.member;
  }

  public void setMember(Member member) {
    this.member = member;
  }

  public RentType getRentType() {
    return this.rentType;
  }

  public void setRentType(RentType rentType) {
    this.rentType = rentType;
  }

  public boolean isFurnished() {
    return this.furnished;
  }

  public void setFurnished(boolean furnished) {
    this.furnished = furnished;
  }

  public Double getPrice() {
    return this.price;
  }

  public void setPrice(Double price) {
    this.price = price;
  }

  public String getWebsiteLink() {
    return this.websiteLink;
  }

  public void setWebsiteLink(String websiteLink) {
    this.websiteLink = websiteLink;
  }

  public String getPhone() {
    return this.phone;
  }

  public void setPhone(String phone) {
    this.phone = phone;
  }

  public String getEmail() {
    return this.email;
  }

  public void setEmail(String email) {
    this.email = email;
  }

  public String getDescription() {
    return this.description;
  }

  public void setDescription(String description) {
    this.description = description;
  }

  public Set<RentPicture> getRentPictures() {
    return this.rentPictures;
  }

  public void setRentPictures(Set<RentPicture> rentPictures) {
    this.rentPictures = rentPictures;
  }

}
